<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<script type="text/javascript">

				function updateArtPic() {
					
						var pice =$("#price").val();
						if(pice.length<1){
							alert("请填写完整。")
							return false;
						}
				$.post("/misc/artPic/updatePic.htm", {
					identifier:$("#identifier").val(),
					painter : $("#painter").val(),
					artSize : $("#artSize").val(),
					material : $("#material").val(),
					title : $("#title").val(),
					content : $("#content").val(),
					count : $("#count").val(),
					price : $("#price").val(),
					priceLow : $("#priceLow").val(),
					priceMax : $("#priceMax").val(),
					type : $("#type").val(),
					years : $("#years").val(),
					madeLink : $("#madeLink").val(),
					imagePath : $("#imagePath").attr("src"),
					imagePath2 : $("#imagePath2").attr("src"),
					imagePath3 :$("#imagePath3").attr("src"),
					imagePath4 : $("#imagePath4").attr("src"),
					imagePath5 : $("#imagePath5").attr("src"),
					artClass : $("#parent_val").val()
				}, function(data) {
					if (data == "success") {
						alert("更新成功！");
					}
					if (data == "error") {
						$.ligerDialog.warn("系统有点抽经，请稍候重试！");
					}
				});
				}
  	function insertArtPic() {
  					var pice =$("#price").val();
  					if(pice.length<1){
  						alert("请填写完整。")
  						return false;
  					}
				$.post("/misc/artPic/insertArtPic.htm", {
					painter : $("#painter").val(),
					artSize : $("#artSize").val(),
					material : $("#material").val(),
					title : $("#title").val(),
					content : $("#content").val(),
					count : $("#count").val(),
					price : $("#price").val(),
					classId : $("#classId").val(),
					type : $("#type").val(),
					years : $("#years").val(),
					madeLink : $("#madeLink").val(),
					imagePath : $("#imagePath").attr("src"),
					imagePath2 : $("#imagePath2").attr("src"),
					imagePath3 :$("#imagePath3").attr("src"),
					imagePath4 : $("#imagePath4").attr("src"),
					imagePath5 : $("#imagePath5").attr("src"),
					artClass : $("#parent_val").val(),
					oldWidth1 : $("#imageWidthimagecontent1").val(),
					oldHeight1 : $("#imageHeightimagecontent1").val()
					
				}, function(data) {
					if (data == "success") {
						 var type = $("#type").val();
						if(type.length<1){
							parent.artPicGrid.loadData();
						}
						alert("添加成功！");
					}
					if (data == "error") {
						$.ligerDialog.warn("系统有点抽经，请稍候重试！");
					}
				});
  	}

	
	//作品分类
	$(function() {
		
		$("#parent").ligerComboBox({
			width : 215,
			selectBoxWidth : 215,
			selectBoxHeight : 180,
			valueField : 'id',
			textField : 'text',
			treeLeafOnly : false,
			tree : {
				checkbox : false,
				btnClickToToggleOnly : false,
				url : '/misc/artPic/classTree.htm?type=${classType}'
			}
		});
		if("${parentId}" != "undefined"){
			$("#parent_val").val("${parentId}");
		}
		
	});
	
	function cleanPic(obj){
		$("#imagePath"+obj).attr("src",".jpg");
		alert("删除成功");
	}
	
	
</script>

					<table width="80%" class="def_t">
						<tr>
							<td>上传图片1：</td>
							<td align="left" class="l-table-edit-td">
							<form id="upload_img_form" enctype="multipart/form-data" method="post" action="/misc/artPic/uploadImg.htm">
								<input type="file" onchange="uploadCmsImg(this);return false;""  style="width: 200px;" title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagecontent" id="imagecontent1" />
								<img src="${artPic.imagePath}" alt="" class="user_img" id="imagePath" width="100px;"height="100px" />　
								<input type="hidden" id="imageWidthimagecontent1" />
								<input type="hidden" id="imageHeightimagecontent1"/>
							</form>
							</td>
							<td><input type="button" value="清空图片" onclick="cleanPic('');"/></td>
						</tr>
					</table>
					
					<table width="80%" class="def_t">
						<tr>
							<td>上传图片2：</td>
							<td align="left" class="l-table-edit-td">
							<form id="upload_img_form" enctype="multipart/form-data" method="post" action="/misc/artPic/uploadImg.htm">
								<input type="file" onchange="uploadCmsImg(this);return false;""  style="width: 200px;" title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagecontent" id="imagecontent2" />
								<img src="${artPic.imagePath2}" alt="" class="user_img" id="imagePath2" width="100px;"height="100px"/>　
							</form>
							</td>
							<td><input type="button" value="清空图片" onclick="cleanPic('2');"/></td>
						</tr>
					</table><table width="80%" class="def_t">
						<tr>
							<td>上传图片3：</td>
							<td align="left" class="l-table-edit-td">
							<form id="upload_img_form" enctype="multipart/form-data" method="post" action="/misc/artPic/uploadImg.htm">
								<input type="file" onchange="uploadCmsImg(this);return false;""  style="width: 200px;" title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagecontent" id="imagecontent3" />
								<img src="${artPic.imagePath3}" alt="" class="user_img" id="imagePath3" width="100px;"height="100px"/>　
							</form>
							</td>
							<td><input type="button" value="清空图片" onclick="cleanPic(3);"/></td>
						</tr>
					</table><table width="80%" class="def_t">
						<tr>
							<td>上传图片4：</td>
							<td align="left" class="l-table-edit-td">
							<form id="upload_img_form" enctype="multipart/form-data" method="post" action="/misc/artPic/uploadImg.htm">
								<input type="file" onchange="uploadCmsImg(this);return false;""  style="width: 200px;" title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagecontent" id="imagecontent4" />
								<img src="${artPic.imagePath4}" alt="" class="user_img" id="imagePath4" width="100px;"height="100px"/>　
							</form>
							</td>
							<td><input type="button" value="清空图片" onclick="cleanPic(4);"/></td>
						</tr>
					</table><table width="80%" class="def_t">
						<tr>
							<td>上传图片5：</td>
							<td align="left" class="l-table-edit-td">
							<form id="upload_img_form" enctype="multipart/form-data" method="post" action="/misc/artPic/uploadImg.htm">
								<input type="file" onchange="uploadCmsImg(this);return false;""  style="width: 200px;" title="支持jpg、jpeg、gif、png格式，文件小于2M" name="imagecontent" id="imagecontent5" />
								<img src="${artPic.imagePath5}" alt="" class="user_img" id="imagePath5" width="100px;"height="100px"/>　
							</form>
							
							</td>
							<td><input type="button" value="清空图片" onclick="cleanPic(5);"/></td>
						</tr>
						
					</table>

<form method="post" id="add_artPic_form" action="">
	<table width="80%" class="def_t">
		<tr>
			<td>作者：</td>
			<td>
				<c:if test="${empty artName}"><input type="text" id="painter" name="painter" value="${ artPic.painter}"/> </c:if>
				<c:if test="${!empty artName}"><input type="text" id="painter" name="painter" value="${artName}"/></c:if>
				<input type="hidden" id="classId" name="classId" value="${classId }"/>
				<input type="hidden" id="type" name="type" value="${type }"/>
				<input type="hidden" id="identifier" name="identifier" value="${artPic.identifier }"/>
			</td>
		</tr>
		<tr>
			<td>定制链接：</td>
			<td><input type="text" id="madeLink" name="madeLink" value="${artPic.madeLink}"/></td>
		</tr>
		<tr>
			<td>分类：</td>
			<td><input type="text" id="parent" value="${artPic.artClassName }"/></td>
		</tr>
		<tr>
			<td>尺寸：</td>
			<td><input type="text" id="artSize" name="artSize" value="${artPic.artSize}"/></td>
		</tr>
		<tr>
			<td>材料：</td>
			<td><input type="text" id="material" name="material" value="${artPic.material}"/></td>
		</tr>
		<tr>
			<td>标题：</td>
			<td><input type="text" id="title" name="title" value="${artPic.title}"/></td>
		</tr>
		<tr>
			<td>描述：</td>
			<td><textarea id="content" name="content" cols="200"
					style="width: 450px">${artPic.content}</textarea></td>
		</tr>
		<tr>
			<td>数量：</td>
			<td><input type="text" id="count" name="count" value="${artPic.count}"/></td>
		</tr>
		<c:if test="${classType eq '001' || classType eq '002' }">
			<input type="text" id="price" name="price" value="9999999"  style="display: none;"/>
		</c:if>
		<c:if test="${classType eq '004' }">
			<tr>
				<td>价格：</td>
				<td><input type="text" id="price" name="price" value="${artPic.price}"/></td>
			</tr>
			<tr>
				<td>促销价格：</td>
				<td><input type="text" id="priceLow" name="priceLow" value="${artPic.priceLow}"/></td>
			</tr>
		</c:if>
		<c:if test="${classType eq '003' }">
			<tr>
				<td>起拍价：</td>
				<td><input type="text" id="price" name="price" value="${artPic.price}"/></td>
			</tr>
			<tr>
				<td>一口价：</td>
				<td><input type="text" id="priceMax" name="priceMax" value="${artPic.priceMax}"/></td>
			</tr>
		</c:if>
		<tr>
			<td>年代：</td>
			<td><input type="text" id="years" name="years" value="${artPic.years}"/></td>
		</tr>

		<tr>
			<td colspan="2" style="text-align: center;">
				<c:if test="${have eq 'no'}">	<input type="button" value="添加" onclick="insertArtPic();"/></c:if>
				<c:if test="${have eq 'have'}">	<input type="button" value="更新" onclick="updateArtPic();"/></c:if>
			</td>
		</tr>
	</table>
</form>
